package com.itheima.基于反射操作成员变量;

import java.lang.reflect.Field;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, InstantiationException {
        Class clazz = Class.forName("com.itheima.基于反射操作成员变量.Teacher");

        Field[] fields = clazz.getFields();
        for (Field field : fields) {
            System.out.println(field);
        }

        System.out.println("--------------------");
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            System.out.println(declaredField);
        }

        System.out.println("-------------------");

        /*System.out.println(clazz.getDeclaredField("count"));*/

        Field declaredField = clazz.getDeclaredField("count");
        declaredField.setAccessible(true);

        Teacher tea = (Teacher) clazz.newInstance();
        Object o = declaredField.get(tea);
        System.out.println(o);




    }
}
